package ExtendDemo.demo04;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;

public class CilentDemo {
    /**
     * TCP发送数据的步骤
     *      1：创建客户端的Socket对象
     *      2：获取输出流，写数据
     *      3：释放资源
     *
     */
    public static void main(String[] args) throws IOException {
//            Socket s=new Socket(InetAddress.getByName("192.168.0.101"),10000);
            Socket s=new Socket("192.168.0.101",10000);

        OutputStream os = s.getOutputStream();
        os.write("hello,TCP,我来了".getBytes(StandardCharsets.UTF_8));

        s.close();



    }
}
